package com.example.mapper;

import com.example.entity.MbtiTestResult;
import com.example.vo.StudentMBTIResult;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MbtiTestResultMapper {
    @Insert("INSERT INTO mbti_test_result(user_id, mbti_type, create_time) " +
            "VALUES(#{userId}, #{mbtiType}, #{createTime})")
    @Options(useGeneratedKeys = true, keyProperty = "resultId")
    void insert(MbtiTestResult result);

    @Select("select * from mbti_test_result where user_id = #{userId} ORDER BY create_time DESC;")
    List<MbtiTestResult> historyTest(Integer userId);

    List<StudentMBTIResult> findLatestMBTIResultsByClassId(Integer classId);
}
